package cn.zhaozhiqi.controller.app;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.zhaozhiqi.pojo.dto.DriverGeoDto;
import cn.zhaozhiqi.pojo.dto.DriverRegisterDto;
import cn.zhaozhiqi.result.JSONResult;
import cn.zhaozhiqi.service.IDriverService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Tag(name = "司机注册",description = "司机注册")
@RestController
@RequestMapping("app/driver")
public class AppDriverController {

    @Autowired
    public IDriverService driverService;



    @Operation( summary= "拿到rocketMQ中的订单",description = "拿到rocketMQ中的订单接口")
    @GetMapping("/getOrderById")
    public JSONResult getOrderById(){
        return JSONResult.success(driverService.getOrderById());
    }

    @Operation( summary= "注册Driver",description = "使用post注册一个新的司机用户")
    @Parameter(name = "传入的DriverRegisterDto",description = "前端传入的信息，例如wx的code",required = true)
    @PostMapping("/resgister")
    @SaIgnore
    public JSONResult<Boolean> driverRegister(@RequestBody @Valid DriverRegisterDto dto){
        return JSONResult.success(driverService.driverRegister(dto));
    }

    @Operation( summary= "拿到控制台需要的司机参数",description = "拿到控制台需要的司机参数接口")
    @GetMapping("/getWorkbench")
    public JSONResult getWorkbench(){
        return JSONResult.success(driverService.getWorkbench());
    }

    @Operation( summary= "司机开始接单",description = "司机开始接单接口")
    @PostMapping("/online")
    public JSONResult online(){
        return JSONResult.success(driverService.online());
    }

    @Operation( summary= "司机停止接单",description = "司机停止接单接口")
    @PostMapping("/offline")
    public JSONResult offline(){
        return JSONResult.success(driverService.offline());
    }

    @Operation( summary= "司机上传GEO坐标",description = "司机上传GEO坐标接口")
    @PostMapping("/saveGeo")
    public JSONResult saveGeo(@RequestBody @Valid DriverGeoDto dto){
        return JSONResult.success(driverService.saveGeo(dto));
    }

}
